@model PostModel

@inject IStringLocalizer<Resource> _localizer

@{
  Layout = "layouts/_main.cshtml"; ;
}

@section FooterScript {
  <script src="~/_content/@ThemesStandardConstant.AssemblyName/js/highlight.js"></script>
}

<main class="post-detail">
  <article class="post">
    <figure class="post-cover">
      <img class="post-cover-img" src="@PageHelper.CheckGetCoverrUrl(Model.PostSlug.Post.Cover)" alt="@Model.PostSlug.Post.Title" aria-hidden="true">
    </figure>
    <header class="post-header post-container">
      <h1 class="post-title">@Model.PostSlug.Post.Title</h1>
      <div class="post-meta d-flex align-items-center">
        <div class="post-meta-item post-meta-author">
          <img class="post-meta-author-img d-none d-md-block" width="32" height="32" src="@PageHelper.CheckGetAvatarUrl(Model.PostSlug.Post.User.Avatar)"
               alt="@Model.PostSlug.Post.User.NickName" aria-hidden="true" />
          <div class="post-meta-author-details">
            <span class="post-meta-label">@_localizer["author"]</span>
            <a class="post-meta-author-name" href="#">@Model.PostSlug.Post.User.NickName</a>
          </div>
        </div>
        <div class="post-meta-item post-meta-date">
          <span class="post-meta-label">@_localizer["published"]</span>
          <time class="post-meta-date-time">@DateTimeHelper.ToFriendlyShortDateString(Model.PostSlug.Post.PublishedAt)</time>
        </div>
        @if (Model.PostSlug.Post.Categories != null && Model.PostSlug.Post.Categories.Count > 0)
        {
          <div class="post-meta-item post-meta-cats">
            <span class="post-meta-label">@_localizer["categories"]</span>
            <ul class="post-meta-cats-list d-flex">
              @foreach (var cat in Model.PostSlug.Post.Categories)
              {
                <li class="post-meta-cats-item">
                  <a class="post-meta-cats-link" href="@Model.CategoriesUrl/@cat.Content">@cat.Content</a>
                </li>
              }
            </ul>
          </div>
        }
        <button class="post-meta-btn ms-auto" type="button" data-bs-toggle="modal" data-bs-target="#shareModal" aria-label="@_localizer["share"]">
          <svg width="16" height="16" class="bi bi-share">
            <use xlink:href="/_content/@ThemesStandardConstant.AssemblyName/img/icon-sprites.svg#bi-share"></use>
          </svg>
        </button>
        @if (User.Identity != null && User.Identity.IsAuthenticated)
        {
          <a class="post-meta-btn ms-2" href="~/admin/blogs/editor/@Model.PostSlug.Post.Slug" role="button" aria-label="@_localizer["edit-post"]">
            <svg width="16" height="16" class="bi bi-pencil">
              <use xlink:href="/_content/@ThemesStandardConstant.AssemblyName/img/icon-sprites.svg#bi-pencil"></use>
            </svg>
          </a>
        }
      </div>
    </header>

    <section class="post-content post-container">
      @Html.Raw(Model.PostSlug.Post.ContentHtml)
    </section>

    <footer class="post-footer post-container">
      <!--
        TODO:
        Custom fields:
        - post author on or off (default)
        - post comments on or off (default)
      -->
      <partial name="post/author.cshtml" />
      <partial name="post/comments.cshtml" />
    </footer>

  </article>

  <div class="container">
    <!--
      TODO:
      Custom fields:
      - post nav on or off (default)
      - post related on (default) or off
      - post share on (default) or off
     -->
    <partial name="post/nav.cshtml" />
    <partial name="post/related.cshtml" />
    <partial name="post/share.cshtml" />
  </div>

</main>
